<template>
	<view>
		<navigator url="/pages/4_10onUnload/4_10onUnload2" open-type="reLaunch">
			跳转到页面2(本页面被卸载)
		</navigator>
		<view v-show="fixed" class="box">↑</view>
		<view v-for="item in 300">{{item}}</view>
	</view>
</template>

<script setup>
import { onUnload,onPageScroll } from '@dcloudio/uni-app'
import { ref } from 'vue';

const fixed = ref(false)

onUnload(()=>{
	console.log("页面被卸载了。。。");
})

onPageScroll((e)=>{
	console.log(e.scrollTop);
	fixed.value = e.scrollTop>300;
})
</script>

<style lang="scss" scoped>
	.box {
		width: 80px;
		height: 80px;
		background: pink;
		position: fixed;
		right: 30px;
		bottom: 30px;
	}       
</style>
